package com.chookss.mine.set

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.chookss.R
import com.lvgroup.hospital.base.BaseAct
import kotlinx.android.synthetic.main.activity_answer_card.common_title_back
import kotlinx.android.synthetic.main.activity_sex.*
import kotlinx.android.synthetic.main.common_title.*


class SexActivity : BaseAct(), View.OnClickListener {

    var sex: String = "男"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_sex)
    }

    override fun initData() {
        initState()
        common_title_txt.text="性别"
        common_right_txt.text="确定"
        common_right_txt.visibility=View.VISIBLE
        common_title_back.setOnClickListener(this)
        rlSex1.setOnClickListener(this)
        rlSex2.setOnClickListener(this)
        common_right_txt.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.common_title_back -> {
                finish()
            }
            R.id.rlSex1 -> {
                ivSex1.visibility = View.VISIBLE
                ivSex2.visibility = View.GONE
                sex = tvSex1.text.toString()
            }
            R.id.rlSex2 -> {
                ivSex1.visibility = View.GONE
                ivSex2.visibility = View.VISIBLE
                sex = tvSex2.text.toString()
            }
            R.id.common_right_txt -> {
                val intent = Intent()
                // 设置返回码和返回携带的数据
                intent.putExtra("newSex", sex)
                setResult(2, intent)
                finish()
            }
        }
    }


}